<?php

class Jenis{
	private $id;
	private $jenis;
	
	function __construct(){}
	
	function setId($id){
		$this->id = $id;
	}
	
	function setJenis($jenis){
		$this->jenis = $jenis;
	}
	
	function getId(){
		return $this->id;
	}
	
	function getJenis(){
		return $this->jenis;
	}

}


class Daftar_jenis{

	function __construct(){}
	
	function getAll(){
		
		$sql="
		select *
		from
		jenis_sk
		";
		
		$list_jenis = array();
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$jenis = new Jenis();
				$jenis->setId($row['kd_jenis_sk']);
				$jenis->setJenis($row['jenis_sk']);
								
				$list_jenis[] = $jenis;
			}
		}	
		return $list_jenis;
	}
	
	function getById($id){
		
		$sql="
		select *
		from
		jenis_sk
		where kd_jenis_sk = '$id'
		";
		
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$jenis = new Jenis();
				$jenis->setId($row['kd_jenis_sk']);
				$jenis->setJenis($row['jenis_sk']);
			
			}
		}	
		return $jenis;
	}
	
	function add(Jenis $jenis){
	
		$sql="
		insert into jenis_sk
		(kd_jenis_sk, jenis_sk)
		values(
		'',
		'".$jenis->getJenis()."')
		";
		
		$query = mysql_query($sql);
		return $query;
	}
	
	function edit(Jenis $jenis){
	
		$sql="
		UPDATE jenis_sk
		SET
		jenis_sk='".$jenis->getJenis()."'
		WHERE
		kd_jenis_sk='".$jenis->getId()."'
		";
		
		$query = mysql_query($sql);
		return $query;
	}
	
	function delete(Jenis $jenis){
	
		$sql="
		delete from jenis_sk
		WHERE
		kd_jenis_sk='".$jenis->getId()."'
		";
		
		$query = mysql_query($sql);
		return $query;
	}
	
	
}